home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / comm / mail / thor201.lha / THOR_2.0 / thor.lha / rexx / UnMime.thor < prev    next >
Text File  |  1995-05-15  |  2KB  |  119 lines

  1. /* $VER: UnMime.thor 3.1 (17.12.1994)
  2.  *
  3.  * Arexx script to convert mime quoted-printable mail messages to 
  4.  * readable text. Assumes charset=iso-8859-1.
  5.  *
  6.  * Will convert the current message when executed from Thor. The 
  7.  * result will be shown in the message listview. 
  8.  *
  9.  * Disclaimer: This script is made without any knowledge of MIME 
  10.  *             encoded messages. :-)
  11.  *
  12.  * Known bugs: Not as speedy as it should have been. :-)
  13.  *
  14.  * Script by: Eivind Nordseth, Ultima Thule Software.
  15.  */
  16.  
  17. /* trace results */
  18.  
  19. parse arg filename
  20.  
  21. TRUE = 1
  22. FALSE = 0
  23.  
  24. if filename = '' then
  25. do
  26.     if(substr(address(),1,4) ~= "THOR") then do
  27.         parse arg thorport
  28.         if~(show(p, thorport)) then do
  29.             if ~(show(p, "THOR.01")) then do
  30.                 say "No THOR port found!"
  31.                 exit
  32.             end
  33.             else thorport = "THOR.01"
  34.         end
  35.     end
  36.     else thorport = address()
  37.     
  38.     thor = TRUE
  39.     
  40.     filename = 't:unmime.tmp'
  41.     outfile = 't:unmime.out.tmp'
  42.  
  43.     address command 'delete >nil:' filename
  44.  
  45.     if(~open('out', outfile, 'Write')) then 
  46.     do
  47.         say 'Failed to open file temp file'
  48.         exit
  49.     end
  50.  
  51.     address(thorport)
  52.     SAVEMESSAGE CURRENT FILE filename noheader
  53.     if(rc ~= 0) then 
  54.     do 
  55.         REQUESTNOTIFY TEXT '"Not able to save current message."' BT '"_Ok"'
  56.         exit
  57.     end
  58. end
  59. else thor = FALSE
  60.  
  61. if(~open('fh', filename, 'Read')) then 
  62. do
  63.     say 'Failed to open file'
  64.     exit
  65. end
  66.  
  67. outline = ''
  68.  
  69. do until eof('fh')
  70.     aline = readln('fh')
  71.  
  72.     donewline = TRUE
  73.     linelen = length(aline)
  74.  
  75.     do n = 1 to linelen
  76.         char = substr(aline, n, 1)    
  77.  
  78.         if char = '=' then
  79.         do
  80.             select
  81.                 when n = linelen then 
  82.                 do
  83.                     donewline = FALSE
  84.                 end
  85.                 when substr(aline, n + 1, 1) = '=' then 
  86.                 do
  87.                     outline = outline || '='
  88.                     n = n + 1
  89.                 end
  90.                 otherwise
  91.                 do
  92.                     outline = outline || x2c(substr(aline, n + 1, 2))
  93.                     n = n + 2
  94.                 end
  95.             end
  96.         end
  97.         else outline = outline || char
  98.     end
  99.     if donewline then 
  100.     do
  101.         if thor then call writeln('out', outline)
  102.         else say outline
  103.         outline = ''
  104.     end
  105. end
  106.  
  107. call close('fh')
  108.  
  109. if thor then 
  110. do
  111.     call close('out')
  112.     SHOWTEXT outfile CURRENTMSGTEXT
  113.      if(rc ~= 0) then 
  114.     do 
  115.         REQUESTNOTIFY TEXT '"Not able to show the converted message."' BT '"_Ok"'
  116.         exit
  117.     end
  118. end
  119.